Grokking Microservices Design Patterns
Rate this course
Ask Author
Contribute
Back to course home

0% completed

Vote For New Content
Introduction
Who Should Take This Course?
The Course at a Glance
Strangler Fig Pattern
Introduction
The Problem: Legacy Systems
The Strangler Pattern: A Solution
The Architecture of the Strangler Pattern
Strangler Pattern: A Detailed Example
Key Insights and Implications
API Gateway Pattern
Introduction to the API Gateway Pattern
Advantages of API Gateway Pattern
API Gateway Pattern: An Example
Performance Implications
System Design Example
Backends for Frontends (BFF) Pattern
Introduction to BFF
The Problem: Traditional Backend Models
The Architecture of the BFF Pattern
BFF Pattern: An Example
Performance Implications
System Design Examples
Service Discovery Pattern
What is Service Discovery Pattern?
The Problem: Service Coordination in Distributed Systems
Service Discovery Pattern: A Solution
The Architecture of the Service Discovery Pattern
The Inner Workings of the Service Discovery Pattern
Service Discovery Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Security Considerations
Circuit Breaker Pattern
Introduction
The Problem: The Struggles of Distributed Systems and Service Failures
The Circuit Breaker Pattern: An Effective Shield Against Cascading Failures
Circuit Breaker Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Summary
Bulkhead Pattern
Introduction
The Problem: Failure Propagation in Distributed Systems
The Bulkhead Pattern: A Solution
The Architecture
The Inner Workings
Bulkhead Pattern: A Example
Performance Implications and Special Considerations
System Design Examples
Conclusion
Retry Pattern
Introduction
The Retry Pattern: A Solution to Unreliable External Resources
The Architecture of the Retry Pattern
Retry Pattern: An Example
Performance Implications
Use Cases and System Design Examples
Conclusion
Sidecar Pattern
Introduction to the Sidecar Pattern
The Problem: Monolithic Application Management
A Solution to the Monolithic Mayhem
The Architecture of the Sidecar Pattern
Sidecar Pattern: Bringing Theory to Practice with an Example
Performance Implications
System Design Examples: Bringing the Sidecar Pattern to Life
Saga Pattern
Introduction to Saga Pattern
The Problem: Traditional Transaction Models
The Saga Pattern: A Solution
The Architecture of the Saga Pattern
The Inner Workings of the Saga Pattern
Saga Pattern: A Example
Performance Implications
System Design Examples
Conclusion
Event-Driven Architecture Pattern
Introduction
The Problem: Managing Complex Interactions in Distributed Systems
Event-Driven Architecture: A Promising Solution
The Architecture of the Event-Driven Architecture Pattern
The Inner Workings of the Event-Driven Architecture Pattern
Event-Driven Architecture Pattern: An Example
Performance Implications and Special Considerations
Use Cases and System Design Examples
Conclusion
Introduction
The Problem: Traditional CRUD Operations
CQRS Pattern: A Solution
The Architecture of the CQRS Pattern
The Inner Workings of the CQRS Pattern
CQRS Pattern: An Example
Issues, Special Considerations, and Performance Implications
System Design Examples
Introduction
The Problem: Configuration Management in a Microservices Architecture
The Solution: Configuration Externalization Pattern
Unveiling the Architecture: How Does Configuration Externalization Work?
Delving into Code: An Example
Considerations and Implications
Use Cases and Real-world Examples
Conclusion
Embrace the Future of Software Architecture
The Inner Workings of the Event-Driven Architecture Pattern

Peeling back the layers of Event-Driven Architecture (EDA) offers us insights into its inner workings and helps us appreciate its elegance. We've grasped the basic architecture, but how does it all come together in a running system? Let's find out!

Event Generation and Propagation

The life of an event starts with a change in state in the system. This could be a user action, a sensor reading, or even an internal system update. An event is then generated to encapsulate this change in state. But how does this process occur?

Event Producers are responsible for generating these events. In essence, an event is a bundle of data representing a significant occurrence in the system. Once an event is generated, it needs to be propagated through the system. Here's where the Event Bus comes into play.

The Event Bus is essentially the spinal cord of the EDA, carrying events from producers to consumers. It does this via Event Channels, pathways that categorize and route events based on their type or nature. These channels ensure the right events reach the right consumers.

But how does the Event Bus determine where to route these events?

Routing and Event Channels

In the Mediator EDA, a central component determines how to route events. Based on the event type, and the known consumers, it makes a decision on the right Event Channel for the event. The Mediator might also aggregate, filter, or transform events before sending them on their way.

On the other hand, in a Broker EDA, there's no central mediator to make this decision. Instead, Event Producers directly place events into Event Channels on the Event Bus. Event Consumers then subscribe to these channels and consume the events directly. Here, the routing mechanism is much simpler, but also less controlled.

This routing is crucial to the operation of the EDA. Without it, events would simply float aimlessly in the system. But with it, events know precisely where to go.

Event Processing and State Change

Once an event reaches its destination, the Event Consumer, it is processed. The consumer takes the event data and performs actions based on it, leading to a change in the system state. This could be anything from changing a value in a database to triggering a physical action in an IoT device.

But how do Event Consumers know when to act?

Event Consumers are always listening. They are set up to monitor their subscribed channels on the Event Bus, waiting for events. Once an event arrives, they jump into action. This 'listening' mechanism is usually implemented using Observer or Publish-Subscribe patterns.

Event-Driven in Real-Time Systems

The real-time operation of an EDA system is a symphony of event generation, propagation, routing, and consumption. To illustrate, consider a traffic management system where various sensors act as Event Producers, generating events for each vehicle detected.

The events travel via the Event Bus, through appropriate channels, to the Event Consumers - traffic signals in this case. Based on the events received (for example, vehicle count), the signals adjust their timing, leading to changes in the system state - the traffic flow in our scenario.

Throughout this process, the system reacts in real-time to changes, demonstrating the power and flexibility of EDA.

Event Sourcing and CQRS

Two significant concepts related to EDA are Event Sourcing and Command Query Responsibility Segregation (CQRS). Event Sourcing means that changes to application state are stored as a sequence of events, not just as a snapshot of the current state. This allows full auditability, versioning, and the ability to "time-travel" to see the state of the system at any point in time.

CQRS, on the other hand, involves separating the read and write operations of a system. This can be especially useful in an EDA, as it allows us to model our event handlers (write operations) separately from our views (read operations).

Wrapping Up The Inner Workings

Unraveling the inner workings of the Event-Driven Architecture helps us grasp its operation on a more profound level. From the creation of events to their consumption, we've traced the lifecycle of an event in an EDA. However, understanding this architecture isn't just about appreciating its operation but also about recognizing its strengths and potential pitfalls.

Do you feel ready to delve into a Java-based example of the Event-Driven Architecture? Are there questions about the operation of the EDA that you still want to explore? Let's proceed on our journey and see this elegant architecture in action in the world of code.

The Architecture of the Event-Driven Architecture Pattern
Event-Driven Architecture Pattern: An Example
Mark as Completed

On this page

Event Generation and Propagation

Routing and Event Channels

Event Processing and State Change

Event-Driven in Real-Time Systems

Event Sourcing and CQRS

Wrapping Up The Inner Workings